Replace header template from plugin

68

function header_override () {
    // $template = locate_template('header.php');

    // load_template(plugin_dir_path( __FILE__ ) . 'templates/header.php');
    // print_r($template);

    if ( $overridden_template = locate_template( 'header.php' ) ) {
        load_template( $overridden_template );
    }else{
        load_template(plugin_dir_path( __FILE__ ) . 'templates/header.php');
    }
}
add_action('template_include', 'header_override');


function new_header_output() {
    remove_action( 'get_header', 'header_output', 20);
    load_template(plugin_dir_path( __FILE__ ) . 'templates/header.php');
}
add_action('get_header', 'new_header_output');


function action_function_name_391( $name, $args ){
    print_r("custom header");
}
add_action( 'get_header', 'action_function_name_391', 10, 2 );

Comments

Submit
0 Comments